# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ldb
pkgver=2.8.0
pkgrel=1
pkgdesc="schema-less, ldap like, API and database"
url="https://ldb.samba.org/"
arch="all"
license="LGPL-3.0-or-later"
makedepends="libtirpc-dev tevent-dev py3-tevent tdb-dev py3-tdb talloc-dev
	python3-dev popt-dev cmocka-dev docbook-xsl lmdb-dev"
subpackages="$pkgname-dev py3-$pkgname:_py3 $pkgname-tools $pkgname-doc"
source="https://www.samba.org/ftp/pub/ldb/ldb-$pkgver.tar.gz
	disable-compile-error-test.patch
	strtoull.patch
	"

# secfixes:
#   1.3.5-r0:
#     - CVE-2018-1140

_waf=buildtools/bin/waf

case "$CARCH" in
	ppc64le) options="$options !check" ;;
	x86|armhf|armv7) options="$options !check" ;;
esac

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	./configure \
		--prefix=/usr \
		--disable-rpath \
		--disable-rpath-install \
		--builtin-libraries=replace \
		--bundled-libraries=NONE \
		--with-modulesdir=/usr/lib/ldb/modules
	make
}

check() {
	make check
}

package() {
	make install DESTDIR="$pkgdir"
}

_py3() {
	pkgdesc="Python 3 binding for the ldb library"
	amove usr/lib/python3* \
		usr/lib/libpyldb-util.cpython*
}

tools() {
	pkgdesc="Tools to manage LDB files"
	amove usr/bin usr/lib/ldb/libldb-cmdline.*
}

sha512sums="
b6f289af3137e02a8e3ee0588bc300d1756b8980558e0b3a3a9eee4449100ccd42ed873187dbdb334e7e7834a8bff8478cd4f20588d4ca834d9ea14c0ee2c2f9  ldb-2.8.0.tar.gz
ed55d5151bbcaf5c0a1b70a1f44b461a501ad94ce02ee97e3ea10c560ce3656a190510697bbd3c5b6f70a74519bf7c0a91210bcb415ffd97d9440045e10a02e8  disable-compile-error-test.patch
8e005bf69759b962b60898a746443a7324ab93dde0e6e21bbeddeb6e49a9cb90152129ef874c8cf82c45291427363307182bb54ce573eee3669ec0f0a251e3cb  strtoull.patch
"
